package DemoText;

/**
 * 三步问题
 */
public class LeetCode0801 {
    public int waysToStep(int n) {
        if (n == 1) return 1;
        if (n == 2) return 2;
        if (n == 3) return 4;
        long a = 1l, b = 2l, c = 4l, d = 0l;
        for (int i = 4; i <= n; i++) {
            d = (a + b + c) % 1000000007;
            a = b; b = c; c = d;
        }
        return (int) d;
    }
}
